package a66weding.com.jiehuntong.adapter;

import android.database.DataSetObserver;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import a66weding.com.jiehuntong.fragment.category.BusinessFragment;
import a66weding.com.jiehuntong.fragment.category.CaseFragment;
import a66weding.com.jiehuntong.fragment.category.CommodityFragment;
import a66weding.com.jiehuntong.fragment.category.PackageFragment;

/**
 * Created by admin on 2016/8/1.
 * 搜索类型适配器
 */
public class CategoryAdapter extends FragmentStatePagerAdapter {
    public static final String TAB_TAG = "@dream@";
    private List<String> mTitles;
    List<Fragment> mFragments;

    public CategoryAdapter(FragmentManager fm, List<String> titles) {
        super(fm);
        this.mTitles = titles;
        mFragments = new ArrayList();
        mFragments.add(new PackageFragment());
        mFragments.add(new CaseFragment());
        mFragments.add(new CommodityFragment());
        mFragments.add(new BusinessFragment());
    }
    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mTitles.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles.get(position).split(TAB_TAG)[0];
    }

    @Override
    public int getItemPosition(Object object) {
        return getItemPosition(object);
    }
}